local kangkai = fk.CreateSkill {
    name = "SP_heg__kangkai",
}

Fk:loadTranslationTable{
    ["SP_heg__kangkai"] = "慷忾",
    [":SP_heg__kangkai"] = "与你势力相同的角色成为【杀】的目标后，你可以交给其一张牌，若为装备牌，其可以使用之并令你摸一张牌。",

    ["#SP_heg__kangkai-invoke"] = "慷忾：你可以交给 %dest 一张牌",
    ["#SP_heg__kangkai-give"] = "慷忾：交给 %dest 一张牌，若为装备牌其可以使用",
    ["#SP_heg__kangkai-use"] = "慷忾：你可以使用%arg",

    ["$SP_heg__kangkai1"] = "典将军，比比看谁杀敌更多！",
    ["$SP_heg__kangkai2"] = "父亲快走，有我殿后！"
}

local H = require "packages.ol_hegemony.util"

kangkai:addEffect(fk.TargetConfirmed, {
    anim_type = "support",
    can_trigger = function(self, event, target, player, data)
      return player:hasSkill(kangkai.name) and data.card.trueName == "slash" and H.compareKingdomWith(target, player)
      and target ~= player and not player:isNude()
    end,
    on_cost = function (self, event, target, player, data)
      local room = player.room
      if room:askToSkillInvoke(player, {
        skill_name = kangkai.name,
        prompt = "#SP_heg__kangkai-invoke::"..target.id,
      }) then
        event:setCostData(self, {tos = {target}})
        return true
      end
    end,
    on_use = function(self, event, target, player, data)
      local room = player.room
      if target.dead then return end
      local cards = room:askToCards(player, {
        skill_name = kangkai.name,
        min_num = 1,
        max_num = 1,
        include_equip = true,
        prompt = "#SP_heg__kangkai-give::"..target.id,
        cancelable = false,
      })[1]
        room:moveCardTo(cards, Card.PlayerHand, target, fk.ReasonGive, kangkai.name, nil, true, player)
        if not table.contains(target:getCardIds("h"), cards) or target.dead then return end
        target:showCards(cards)
        if not table.contains(target:getCardIds("h"), cards) or target.dead then return end
        local card = Fk:getCardById(cards)
        if card.type == Card.TypeEquip then
          if room:askToUseRealCard(target, {
           pattern = {cards},
           skill_name = kangkai.name,
           prompt = "#SP_heg__kangkai-use:::"..Fk:getCardById(cards):toLogString(),
           cancelable = true,
          }) then
          player:drawCards(1, kangkai.name)
        end
      end
    end,
  })

return kangkai